<?php include_once("../Adminincludes/config.php");
if(isset($_POST['mode']) && $_POST['mode']=="login" && isset($_POST['submit']))

{

	$UserNameLogin=trim($_POST['username']);	
	$UserPassLogin=$_POST['password'];
	$UserPassLoginMd5=md5($UserPassLogin);	
	$ValidUser="select adminId,adminUser  from  ".ADMIN."  where status='Y' and adminUser='".$UserNameLogin."' and adminPass='".$UserPassLoginMd5."'";	
	$ValidUserQuery=mysql_query($ValidUser) or die('loginerror'.mysql_error());
if(mysql_num_rows($ValidUserQuery)>0)
	{
	
		$_SESSION['msg']="";
		
		$FecthUser=mysql_fetch_array($ValidUserQuery);
		
		$DatabaseUserId=$FecthUser['adminId'];
		
		$DatabaseUserName=$FecthUser['adminUser'];
		
		$TimeStamp=date("Y-m-d H:i:s");
		
		mysql_query("Update ".ADMIN." set lastLogin='".$TimeStamp."' where adminId='".$DatabaseUserId."'");		
		session_register("adminUser");		
		session_register("adminId");		
		$_SESSION['adminId']=$DatabaseUserId;		
		$_SESSION['adminUser']=$DatabaseUserName;	
		header("location:adminhome.php");	
	}
else 
	{
	$_SESSION['msg']="Invalid Username & Password ";	
	header("location:".$site_url."/admin");	
	}

}

?>